#include "ffmpegEnc/ffmpeg.h"
#include <pthread.h>
#define PORT1 "3490"  // the port users will be connecting to
#define PORT2 "3491"  // the port users will be connecting to
#define PORT3 "3492"  // the port users will be connecting to
#define PORT4 "3493"  // the port users will be connecting to

#define FRAMES_TO_ENCODE (30)
#define RGBBITRATE "400k"
#define DEPTHBITRATE "20k"
#define VIDEOFORMAT "try.mp4"
#define RGB_VIDEO_SIZE (300000)
#define DEPTH_VIDEO_SIZE (1000000)

#define VIDEO_HEADER_BYTES (10)
#define BACKLOG 10	 // how many pending connections queue will hold
#define TIMESTAMP_BYTES (10)
#define CUR_TIME_BYTES (20)

unsigned char rgbData[FREENECT_VIDEO_RGB_SIZE*FRAMES_TO_ENCODE];
unsigned char rgbData_back[FREENECT_VIDEO_RGB_SIZE*FRAMES_TO_ENCODE];
int rgbTotalSize=(TIMESTAMP_BYTES+CUR_TIME_BYTES)*FRAMES_TO_ENCODE+VIDEO_HEADER_BYTES+RGB_VIDEO_SIZE;

unsigned char buf[(TIMESTAMP_BYTES+CUR_TIME_BYTES)*FRAMES_TO_ENCODE];
unsigned char buf_back[(TIMESTAMP_BYTES+CUR_TIME_BYTES)*FRAMES_TO_ENCODE];

unsigned char depthData[FREENECT_DEPTH_11BIT_SIZE*FRAMES_TO_ENCODE];
unsigned char depthData_back[FREENECT_DEPTH_11BIT_SIZE*FRAMES_TO_ENCODE];
int depthTotalSize=(TIMESTAMP_BYTES+CUR_TIME_BYTES)*FRAMES_TO_ENCODE+VIDEO_HEADER_BYTES+DEPTH_VIDEO_SIZE;

unsigned char accelData[TIMESTAMP_BYTES+CUR_TIME_BYTES+12];//accelTotalSize=TIMESTAMP_BYTES+CUR_TIME_BYTES+sizeof(freenect_raw_tilt_state state)
int accelTotalSize=TIMESTAMP_BYTES+CUR_TIME_BYTES+12;

unsigned char *rgb_shared_seg,*depth_shared_seg;
key_t keyRgb,keyDepth;
int shmidDepth,shmidrgb;
struct sigaction sigact;

int flag_back=0;

pthread_mutex_t compress_mutex = PTHREAD_MUTEX_INITIALIZER;
